from google.appengine.ext import webapp
from DataClass.FileData import FileData
from google.appengine.api import users
from google.appengine.ext.webapp import template
from AdminBase import AdminBase
from DataClass.WebsiteRec import WebsiteRec
from google.appengine.ext import db

import os
import cgi

class EditFileHandler(AdminBase):
    def GetTemplateFileName(self):
        return 'Pages/editfile.html'
        
    def GetBreadcrumbList(self):
        Website = WebsiteRec.GetCurrentWebsite(self.request)
        return [['main', 'admin'],['files', 'editfiles'],['editfile']]
    
    def GetTemplateValuesDict(self, template_values, user):
        retval = template_values
                                  
        return retval

    def DoPost(self, user):
        lnewFileData = FileData()
        lnewFileData.sitename = self.request.get('sitename')
        lnewFileData.authoremail = user.email()

        lnewFileData.filename = self.request.get('filename')
        lnewFileData.mimetype = self.request.get('mimetype')
        lnewFileData.bytes = db.Blob(self.request.get("filedata"))
        lnewFileData.put()
        self.redirect('/editfiles')
